package main

import "fmt"

type Iterator struct {
	len, index int
}

type IntIterator struct {
	*Iterator
	data []int
}

func NewIntIterator(data []int) *IntIterator {
	return &IntIterator{
		data:     data,
		Iterator: &Iterator{len: len(data)},
	}

}

func (this *Iterator) HasNext() bool {
	if this.len == 0 {
		return false
	}
	return this.index < this.len

}

func (this *IntIterator) Next() int {
	defer func() {
		this.index++
	}()

	return this.data[this.index]
}

func main() {

	iit := NewIntIterator([]int{1, 34, 5, 6, 7, 3})
	for iit.HasNext() {
		fmt.Println(iit.Next())
	}
}
